<template>
  <svg class="svg-icon" :style="styles" aria-hidden="true">
    <use :xlink:href="`#icon-${icon}`"></use>
  </svg>
</template>

<script>
import { computed } from 'vue';
export default {
  name: 'SvgIcon',
  props: {
    name: {
      type: String,
      default: ''
    },
    width: {
      type: Number || String,
      default: 24 || '24px'
    },
    height: {
      type: Number || String,
      default: 24 || '24px'
    }
  },
  setup(props) {
    const icon = computed(() => props.name);
    const styles = computed(() => {
      const { width, height } = props;
      const styles = {
        width: typeof width === 'number' ? String(width) + 'px' : width,
        height: typeof height === 'number' ? String(height) + 'px' : height
      };
      return styles;
    });

    return {
      icon,
      styles
    };
  }
};
</script>

<style scoped>
.svg-icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  vertical-align: -0.15em;
  fill: currentColor;
  overflow: hidden;
}
</style>
